<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        #shop-car li {
            border: 1px dotted red;
            margin: 20px 0;
            padding: 20px;
        }

        .container {
            width: 400px;
            padding: 20px;
        }
    </style>
</head>

<body>
    <div class="container">
        <ul id="shop-car">
            <!-- <li>
                <input type="checkbox" />
                <div>商品名称:</div>
                <img src="https://img12.360buyimg.com/n0/s80x80_jfs/t1/118064/27/12885/59959/5f17b7efE453f688d/5b33ac76b2aaea9b.jpg" alt="">
                <div>商品价格:50</div>
                <div>购买数量:30</div>
                <div>商品规格: 黑</div>
                <div>是否选中：选中吧OR不选中</div>
            </li>
            <li>
                <input type="checkbox" />
                <div>商品名称:</div>
                <img src="https://img12.360buyimg.com/n0/s80x80_jfs/t1/118064/27/12885/59959/5f17b7efE453f688d/5b33ac76b2aaea9b.jpg" alt="">
                <div>商品价格:50</div>
                <div>购买数量:30</div>
                <div>商品规格: 黑</div>
                <div>是否选中：选中吧OR不选中</div>
            </li> -->
        </ul>
        <p id="totalnum">总数量：xxx</p>

    </div>
    <script src="./jquery.js"></script>
    <script src="./zuoye2.js"></script>
    <script>
        // 渲染数据
        let str = '';
        for (let i = 0; i < cartGoods.length; i++) {
            str += `<li>\
                <input type="checkbox" />\
                <div>商品名称:${cartGoods[i].goodsname}</div>\
                <img src="${products[i].goods_img}" alt="">\
                <div>商品价格:${cartGoods[i].price}</div>\
                <div class='num'>购买数量:${products[i].goods_num}</div>\
                <div>商品规格: ${products[i].goods_attr}</div>\
                <div class='select'>是否选中：${cartGoods[i].isChecked ? '选中吧' : '不选中'}</div>\
            </li>`
        }
        // 渲染到ul里面
        $('ul').html(str);
        // 判断复选框的是否全选
        $('ul input').click(function(){
            if($('ul input').length==$('ul :checked').length){
                console.log('全选');
            }else{
                console.log('未全选');
            }
        })

        


    </script>
</body>

</html>